from django.test import TestCase
# Create your tests here.
from pymysql.converters import escape_string
from SQL_CRUD_Interface.CRUD import select_interface


def get_complexity_0_word():
    complexity_0_words = '      select `english` from `tb_word` where `complexity` = "0"    '
    complexity_0_words_tuple = select_interface("127.0.0.1", "root", "root", "study_english_database", complexity_0_words)
    complexity_0_words_list = []
    for ii in complexity_0_words_tuple:
        complexity_0_words_list.append(ii[0].lower())
    return complexity_0_words_list


def get_chinese(english):
    sql2 = '      select `chinese` from `tb_word` where `english` = "%s"    '  % escape_string(english)
    chinese = select_interface("127.0.0.1", "root", "root", "study_english_database",sql2)
    chinese = chinese[0][0]
    return chinese


#  I aingt exactly lactating right now, pal
def get_movie_script(word):
    word = '%' + word + '%'
    sql3 = " SELECT  `english`,`chinese`  FROM `tb_movie_script`   where `english` LIKE  '%s'     " % escape_string(word)
    result = select_interface("127.0.0.1", "root", "root", "study_english_database", sql3)
    return result

